<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newlist" :key="item.id">
        <router-link :to="'/home/newInfo/'+item.id">
          <img class="mui-media-object mui-pull-left" src="https://avatars0.githubusercontent.com/u/42566669?s=40&v=4">
          <div class="mui-media-body">
            <h3>{{ item.title }}</h3>
            <p class="mui-ellipsis">
              <span>{{ item.add_time | dataFormat  }}</span>
              <span>被浏览了{{ item.click }}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { Toast } from "mint-ui";

export default {
  data: function() {
    return {
      newlist: []
    };
  },
  created: function() {
    this.getNewslist();
  },
  methods: {
    getNewslist: function() {
      this.$http.get("api/getnewslist")
      .then(results => {
        if (results.body.status === 0) {
          console.log(results.body.message);
          this.newlist = results.body.message;
        } else {
          Toast("加载新闻列表失败");
        }
      },(err)=>{
            Toast('数据加载失败！');
        });
    }
  }
};
</script>

<style lang="scss" scoped>
    .mui-media-body{
        h3{
            font-size: 12px;
            font-weight:400;
        }
        .mui-ellipsis{
            font-size: 10px;
            display:flex;
            justify-content:space-between;
            
        }
    }
</style>
